package org.dyndns.opendemogroup.optimizer;

/**
 * Represents the results of an optimization run.
 */
public class RunResult
{
	// { public fields
	public double MinFitness = Double.MAX_VALUE;

	public double MaxFitness = Double.MIN_VALUE;

	public double BestFitness;

	public double WorstFitness;

	public int NumberOfGenerations;

	public Member BestMember;

	public int NumberOfEvaluations;

	// }

	public void Update ( Population population, boolean isMaximizing )
	{
		final int populationSize = population.getPopulationSize ( );
		MinFitness =
			Math.min ( MinFitness, population.members[0].getFitness ( ) );
		MaxFitness =
			Math.max ( MaxFitness, population.members[populationSize - 1]
					.getFitness ( ) );

		// TODO: is it necessary that Population also maintain this information?
		if ( isMaximizing )
		{
			BestFitness = MaxFitness;
			WorstFitness = MinFitness;
		}
		else
		{
			BestFitness = MinFitness;
			WorstFitness = MaxFitness;
		}

	}
}
